<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<script>
			//直接插入排序(带哨兵)
			let arr = [0,49,38,65,97,76,13,27,49];
			function sort(arr, n){
				let i,j;
				for(i = 2;i<n;i++){
					// debugger
					if(arr[i - 1] >arr[i]){
						arr[0] = arr[i];
						for(j = i - 1;arr[j]>arr[0];j--){
							arr[j+1] =arr[j];
						}
						arr[j+1] = arr[0];
					}
					
				}
				return arr;
			}
			console.log(sort(arr,arr.length));
		</script>
	</body>
</html>
